<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="org.apache.commons.lang.time.DateFormatUtils"%>
<%@page import="org.springframework.util.CollectionUtils"%>
<%@page import="java.util.Collection"%>
<%@ include file="../common/common_include.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	SettingForm form = (SettingForm)request.getAttribute("command");
	List<TblOaAuthRole> roleList = (List<TblOaAuthRole>)request.getAttribute("roleList");
	String roleDesc  = (null!=form.getRoleDesc())?form.getRoleDesc():"";
%>



<div class="userListWrap" id="userListWrap">
	
	<form id="userListForm">
        <div class="form-item">
    		<label for="roleDesc">角色名称:</label>
    		<input class="easyui-validatebox" type="text" name="roleDesc" data-options="" value="<%=roleDesc%>"/>
        </div>
        <div class="form-item form-item">
    		<a href="javascript:XF.Setting.listRoleSearch()" class="input-btn-microsoft input-btn-microsoft-24">搜索</a>
        </div>
    </form>

    <table id="roleListTable" class="easyui-datagrid"  title="" >
        <thead>
    		<tr>
    			<th data-options="field:'select',width:80,align:'center',checkbox:'true'"><input type="checkbox"></th>
    			<!-- <th data-options="field:'id',width:80">序号</th> -->
    			<th data-options="field:'roleDesc',width:150" orderByField='roleDesc' >
					<a class="order-field" href="javascript:XF.Setting.listRoleSearch('roleDesc')" >角色名称</a>
					<%
						if(StringUtils.isNotBlank(form.getOrderByField()) && StringUtils.isNotBlank(form.getOrderByMode())){
							if("roleDesc".equalsIgnoreCase(form.getOrderByField())){
								if("asc".equalsIgnoreCase(form.getOrderByMode())){
									%><span class="px t" orderByMode='desc'>&nbsp;</span><%
								}else if("desc".equalsIgnoreCase(form.getOrderByMode())){
									%><span class="px d" orderByMode='asc'>&nbsp;</span><%
								}else{
									%><span class="px" orderByMode='asc'>&nbsp;</span><%
								}
							}else{
								%><span class="px" orderByMode='asc'>&nbsp;</span><%
							}
						}else{
							%><span class="px" orderByMode='asc'>&nbsp;</span><%
						}
					%>
				</th>
    			<th data-options="field:'permissions',width:300">权限</th>
    			<th data-options="field:'opr',width:100">操作</th>
    		</tr>
        </thead>
        <tbody>
        	<%
        		if(!CollectionUtils.isEmpty(roleList)){
        			for(int i=0;i<roleList.size();i++){
        				TblOaAuthRole role = roleList.get(i);
        				String permissionNames = StringUtils.isNotBlank(role.getPermissionNames())?role.getPermissionNames():"";
        				if(permissionNames.length()>40){
        					permissionNames = permissionNames.substring(0, 40)+"...";
        				}
        				%>
       					 <tr>
			    			<td></td>
			    			<%-- <td><%=(i+1) %></td> --%>
			    			<td><i s="<%=EncrypTool.encode(role.getRoleId()+"")%>"/><%=role.getRoleDesc()%></td>
			    			<td><a class="aText" title="<%=StringUtils.isNotBlank(role.getPermissionNames())?role.getPermissionNames():"" %>"><%=permissionNames %></a></td>
			    			<td>
			    				<a class="inLink" href="javascript:XF.Setting.editRole('<%=EncrypTool.encode(role.getRoleId()+"")%>')"><span>编辑</span></a>
			    				<a href="javascript:XF.Setting.deleteRole('<%=EncrypTool.encode(role.getRoleId()+"")%>','<%=role.getRoleDesc()%>')"><span>删除</span></a>
			    			</td>
			    		</tr>
        				<%
        			}
        		}
        	%>
    	</tbody>
    </table>
    <div class="pagination">
		<monggoTag:pagination 
		href="listRole_search"
		pageSize="<%=form.getPageSize()%>" 
		totalRecord="<%=form.getTotalRecord() %>" 
		currentPage="<%=form.getPageNum() %>">
		</monggoTag:pagination> 
	</div>
</div>
<script>
	$('#roleListTable').datagrid(); 
</script>